library("FRESA.CAD")
library(readxl)
library(igraph)
library(umap)
library(tsne)
library(entropy)
op <- par(no.readonly = TRUE)
pander::panderOptions('digits', 3)
pander::panderOptions('table.split.table', 400)
pander::panderOptions('keep.trailing.zeros',TRUE)
Data from the speech features
pd_speech_features <- as.data.frame(read_excel("~/GitHub/FCA/Data/pd_speech_features.xlsx",sheet = "pd_speech_features", range = "A2:ACB758"))
Each subject had three repeated observations. Here I’ll use the average of the three experiments per subject.
rep1Parkison <- subset(pd_speech_features,RID==1)
rownames(rep1Parkison) <- rep1Parkison$id
rep1Parkison$id <- NULL
rep1Parkison$RID <- NULL
rep1Parkison[,1:ncol(rep1Parkison)] <- sapply(rep1Parkison,as.numeric)
rep2Parkison <- subset(pd_speech_features,RID==2)
rownames(rep2Parkison) <- rep2Parkison$id
rep2Parkison$id <- NULL
rep2Parkison$RID <- NULL
rep2Parkison[,1:ncol(rep2Parkison)] <- sapply(rep2Parkison,as.numeric)
rep3Parkison <- subset(pd_speech_features,RID==3)
rownames(rep3Parkison) <- rep3Parkison$id
rep3Parkison$id <- NULL
rep3Parkison$RID <- NULL
rep3Parkison[,1:ncol(rep3Parkison)] <- sapply(rep3Parkison,as.numeric)
whof <- !(colnames(rep1Parkison) %in% c("gender","class"));
avgParkison <- rep1Parkison;
avgParkison[,whof] <- (rep1Parkison[,whof] + rep2Parkison[,whof] + rep3Parkison[,whof])/3
signedlog <- function(x) { return (sign(x)*log(abs(1.0e12*x)+1.0))}
whof <- !(colnames(avgParkison) %in% c("gender","class"));
avgParkison[,whof] <- signedlog(avgParkison[,whof])
studyName <- "Parkinsons"
dataframe <- avgParkison
outcome <- "class"
TopVariables <- 10
thro <- 0.80
cexheat = 0.15
Some libraries
library(psych)
library(whitening)
library("vioplot")
library("rpart")
pander::pander(c(rows=nrow(dataframe),col=ncol(dataframe)-1))
| rows | col |
|---|---|
| 252 | 753 |
pander::pander(table(dataframe[,outcome]))
| 0 | 1 |
|---|---|
| 64 | 188 |
varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]
largeSet <- length(varlist) > 1500
Scaling and removing near zero variance columns and highly co-linear(r>0.99999) columns
### Some global cleaning
sdiszero <- apply(dataframe,2,sd) > 1.0e-16
dataframe <- dataframe[,sdiszero]
varlist <- colnames(dataframe)[colnames(dataframe) != outcome]
tokeep <- c(as.character(correlated_Remove(dataframe,varlist,thr=0.99999)),outcome)
dataframe <- dataframe[,tokeep]
varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]
iscontinous <- sapply(apply(dataframe,2,unique),length) >= 5 ## Only variables with enough samples
dataframeScaled <- FRESAScale(dataframe,method="OrderLogit")$scaledData
numsub <- nrow(dataframe)
if (numsub > 1000) numsub <- 1000
if (!largeSet)
{
hm <- heatMaps(data=dataframeScaled[1:numsub,],
Outcome=outcome,
Scale=TRUE,
hCluster = "row",
xlab="Feature",
ylab="Sample",
srtCol=45,
srtRow=45,
cexCol=cexheat,
cexRow=cexheat
)
par(op)
}
The heat map of the data
if (!largeSet)
{
par(cex=0.6,cex.main=0.85,cex.axis=0.7)
#cormat <- Rfast::cora(as.matrix(dataframe[,varlist]),large=TRUE)
cormat <- cor(dataframe[,varlist],method="pearson")
cormat[is.na(cormat)] <- 0
gplots::heatmap.2(abs(cormat),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Original Correlation",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Pearson Correlation|",
xlab="Feature", ylab="Feature")
diag(cormat) <- 0
print(max(abs(cormat)))
}
[1]
0.9999951
DEdataframe <- IDeA(dataframe,verbose=TRUE,thr=thro)
#>
#> tqwt_maxValue_dec_8 det_LT_TKEO_mean_1_coef tqwt_skewnessValue_dec_1 tqwt_skewnessValue_dec_34 mean_delta_delta_0th tqwt_skewnessValue_dec_9
#> PPE DFA RPDE numPulses
#> 0.3198925 0.2836022 0.3037634 0.8534946
#> numPeriodsPulses meanPeriodPulses
#> 0.8494624 0.3830645
#>
#> Included: 744 , Uni p: 0.0002016129 , Base Size: 80 , Rcrit: 0.2212033
#>
#>
1 <R=1.000,thr=0.950>, Top: 74< 47 >[Fa= 74 ]( 74 , 256 , 0 ),<|><>Tot Used: 330 , Added: 256 , Zero Std: 0 , Max Cor: 1.000
#>
2 <R=1.000,thr=0.950>, Top: 36< 8 >[Fa= 109 ]( 36 , 95 , 74 ),<|><>Tot Used: 391 , Added: 95 , Zero Std: 0 , Max Cor: 0.999
#>
3 <R=0.999,thr=0.950>, Top: 19< 5 >[Fa= 127 ]( 18 , 42 , 109 ),<|><>Tot Used: 421 , Added: 42 , Zero Std: 0 , Max Cor: 0.999
#>
4 <R=0.999,thr=0.950>, Top: 3< 2 >[Fa= 130 ]( 3 , 6 , 127 ),<|><>Tot Used: 424 , Added: 6 , Zero Std: 0 , Max Cor: 0.950
#>
5 <R=0.950,thr=0.900>, Top: 74< 2 >[Fa= 162 ]( 71 , 92 , 130 ),<|><>Tot Used: 460 , Added: 92 , Zero Std: 0 , Max Cor: 0.981
#>
6 <R=0.981,thr=0.950>, Top: 2< 1 >[Fa= 162 ]( 2 , 2 , 162 ),<|><>Tot Used: 460 , Added: 2 , Zero Std: 0 , Max Cor: 0.949
#>
7 <R=0.949,thr=0.900>, Top: 12< 1 >[Fa= 165 ]( 11 , 13 , 162 ),<|><>Tot Used: 461 , Added: 13 , Zero Std: 0 , Max Cor: 0.978
#>
8 <R=0.978,thr=0.950>, Top: 1< 1 >[Fa= 165 ]( 1 , 1 , 165 ),<|><>Tot Used: 461 , Added: 1 , Zero Std: 0 , Max Cor: 0.912
#>
9 <R=0.912,thr=0.900>, Top: 2< 1 >[Fa= 165 ]( 2 , 2 , 165 ),<|><>Tot Used: 461 , Added: 2 , Zero Std: 0 , Max Cor: 0.900
#>
10 <R=0.900,thr=0.800>, Top: 76< 5 >[Fa= 191 ]( 70 , 119 , 165 ),<|><>Tot Used: 497 , Added: 119 , Zero Std: 0 , Max Cor: 0.956
#>
11 <R=0.956,thr=0.950>, Top: 1< 1 >[Fa= 191 ]( 1 , 1 , 191 ),<|><>Tot Used: 497 , Added: 1 , Zero Std: 0 , Max Cor: 0.948
#>
12 <R=0.948,thr=0.900>, Top: 4< 1 >[Fa= 193 ]( 4 , 4 , 191 ),<|><>Tot Used: 497 , Added: 4 , Zero Std: 0 , Max Cor: 0.900
#>
13 <R=0.900,thr=0.800>, Top: 23< 1 >[Fa= 198 ]( 21 , 27 , 193 ),<|><>Tot Used: 504 , Added: 27 , Zero Std: 0 , Max Cor: 0.921
#>
14 <R=0.921,thr=0.900>, Top: 1< 1 >[Fa= 199 ]( 1 , 1 , 198 ),<|><>Tot Used: 504 , Added: 1 , Zero Std: 0 , Max Cor: 0.900
#>
15 <R=0.900,thr=0.800>, Top: 7< 2 >[Fa= 200 ]( 7 , 8 , 199 ),<|><>Tot Used: 506 , Added: 8 , Zero Std: 0 , Max Cor: 0.834
#>
16 <R=0.834,thr=0.800>, Top: 2< 1 >[Fa= 200 ]( 2 , 2 , 200 ),<|><>Tot Used: 506 , Added: 2 , Zero Std: 0 , Max Cor: 0.799
#>
17 <R=0.799,thr=0.800>
#>
[ 17 ], 0.798067 Decor Dimension: 506 Nused: 506 . Cor to Base: 267 , ABase: 744 , Outcome Base: 0
#>
varlistc <- colnames(DEdataframe)[colnames(DEdataframe) != outcome]
pander::pander(sum(apply(dataframe[,varlist],2,var)))
57178
pander::pander(sum(apply(DEdataframe[,varlistc],2,var)))
55135
pander::pander(entropy(discretize(unlist(dataframe[,varlist]), 256)))
4.68
pander::pander(entropy(discretize(unlist(DEdataframe[,varlistc]), 256)))
3.21
varratio <- attr(DEdataframe,"VarRatio")
pander::pander(tail(varratio))
| La_app_entropy_shannon_5_coef | La_app_det_TKEO_mean_6_coef | La_app_LT_TKEO_mean_10_coef | La_app_det_TKEO_mean_8_coef | La_app_entropy_log_8_coef | La_app_LT_TKEO_mean_9_coef |
|---|---|---|---|---|---|
| 5.19e-05 | 3.63e-05 | 2.71e-05 | 1.08e-05 | 3.25e-06 | 2.64e-06 |
if (!largeSet)
{
par(cex=0.6,cex.main=0.85,cex.axis=0.7)
UPLTM <- attr(DEdataframe,"UPLTM")
gplots::heatmap.2(1.0*(abs(UPLTM)>0),
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Decorrelation matrix",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Beta|>0",
xlab="Output Feature", ylab="Input Feature")
par(op)
}
Displaying the features associations
par(op)
#if ((ncol(dataframe) < 1000) && (ncol(dataframe) > 10))
#{
# DEdataframeB <- ILAA(dataframe,verbose=TRUE,thr=thro,bootstrap=30)
transform <- attr(DEdataframe,"UPLTM") != 0
tnames <- colnames(transform)
colnames(transform) <- str_remove_all(colnames(transform),"La_")
transform <- abs(transform*cor(dataframe[,rownames(transform)])) # The weights are proportional to the observed correlation
VertexSize <- attr(DEdataframe,"fscore") # The size depends on the variable independence relevance (fscore)
names(VertexSize) <- str_remove_all(names(VertexSize),"La_")
VertexSize <- 10*(VertexSize-min(VertexSize))/(max(VertexSize)-min(VertexSize)) # Normalization
VertexSize <- VertexSize[rownames(transform)]
rsum <- apply(1*(transform !=0),1,sum) + 0.01*VertexSize + 0.001*varratio[tnames]
csum <- apply(1*(transform !=0),2,sum) + 0.01*VertexSize + 0.001*varratio[tnames]
ntop <- min(10,length(rsum))
topfeatures <- unique(c(names(rsum[order(-rsum)])[1:ntop],names(csum[order(-csum)])[1:ntop]))
rtrans <- transform[topfeatures,]
csum <- (apply(1*(rtrans !=0),2,sum) > 1)
rtrans <- rtrans[,csum]
topfeatures <- unique(c(topfeatures,colnames(rtrans)))
print(ncol(transform))
#> [1] 506
transform <- transform[topfeatures,topfeatures]
print(ncol(transform))
#> [1] 41
if (ncol(transform)>100)
{
csum <- (apply(1*(transform !=0),2,sum) > 1) & (apply(1*(transform !=0),1,sum) > 1)
transform <- transform[csum,csum]
print(ncol(transform))
}
if (ncol(transform) < 150)
{
gplots::heatmap.2(transform,
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Red Decorrelation matrix",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Beta|>0",
xlab="Output Feature", ylab="Input Feature")
par(op)
VertexSize <- VertexSize[colnames(transform)]
gr <- graph_from_adjacency_matrix(transform,mode = "directed",diag = FALSE,weighted=TRUE)
gr$layout <- layout_with_fr
fc <- cluster_optimal(gr)
plot(fc, gr,
edge.width = 2*E(gr)$weight,
vertex.size=VertexSize,
edge.arrow.size=0.5,
edge.arrow.width=0.5,
vertex.label.cex=(0.15+0.05*VertexSize),
vertex.label.dist=0.5 + 0.05*VertexSize,
main="Top Feature Association")
}
par(op)
if (!largeSet)
{
cormat <- cor(DEdataframe[,varlistc],method="pearson")
cormat[is.na(cormat)] <- 0
gplots::heatmap.2(abs(cormat),
trace = "none",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "Correlation after ILAA",
cexRow = cexheat,
cexCol = cexheat,
srtCol=45,
srtRow=45,
key.title=NA,
key.xlab="|Pearson Correlation|",
xlab="Feature", ylab="Feature")
par(op)
diag(cormat) <- 0
print(max(abs(cormat)))
}
[1]
0.79933
classes <- unique(dataframe[1:numsub,outcome])
raincolors <- rainbow(length(classes))
names(raincolors) <- classes
topvars <- univariate_BinEnsemble(dataframe,outcome)
lso <- LASSO_MIN(formula(paste(outcome,"~.")),dataframe,family="binomial")
topvars <- unique(c(names(topvars),lso$selectedfeatures))
pander::pander(head(topvars))
std_9th_delta_delta, tqwt_entropy_log_dec_12, std_delta_log_energy, std_delta_delta_log_energy, tqwt_TKEO_std_dec_12 and std_8th_delta_delta
# names(topvars)
#if (nrow(dataframe) < 1000)
#{
datasetframe.umap = umap(scale(dataframe[1:numsub,topvars]),n_components=2)
# datasetframe.umap = umap(dataframe[1:numsub,varlist],n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: Original",t='n')
text(datasetframe.umap$layout,labels=dataframe[1:numsub,outcome],col=raincolors[dataframe[1:numsub,outcome]+1])
#}
varlistcV <- names(varratio[varratio >= 0.025])
topvars <- univariate_BinEnsemble(DEdataframe[,varlistcV],outcome)
lso <- LASSO_MIN(formula(paste(outcome,"~.")),DEdataframe,family="binomial")
topvars <- unique(c(names(topvars),lso$selectedfeatures))
pander::pander(head(topvars))
std_delta_log_energy, La_tqwt_kurtosisValue_dec_33, La_tqwt_stdValue_dec_32, std_9th_delta, tqwt_entropy_log_dec_13 and mean_MFCC_2nd_coef
varlistcV <- varlistcV[varlistcV != outcome]
# DEdataframe[,outcome] <- as.numeric(DEdataframe[,outcome])
#if (nrow(dataframe) < 1000)
#{
datasetframe.umap = umap(scale(DEdataframe[1:numsub,topvars]),n_components=2)
# datasetframe.umap = umap(DEdataframe[1:numsub,varlistcV],n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: After ILAA",t='n')
text(datasetframe.umap$layout,labels=DEdataframe[1:numsub,outcome],col=raincolors[DEdataframe[1:numsub,outcome]+1])
#}
univarRAW <- uniRankVar(varlist,
paste(outcome,"~1"),
outcome,
dataframe,
rankingTest="AUC")
100 : std_MFCC_2nd_coef 200 : app_entropy_log_3_coef 300 :
app_LT_TKEO_mean_7_coef 400 : tqwt_entropy_log_dec_15 500 :
tqwt_medianValue_dec_7
600 : tqwt_stdValue_dec_35 700 : tqwt_skewnessValue_dec_27
univarDe <- uniRankVar(varlistc,
paste(outcome,"~1"),
outcome,
DEdataframe,
rankingTest="AUC",
)
100 : La_std_MFCC_2nd_coef 200 : app_entropy_log_3_coef 300 :
La_app_LT_TKEO_mean_7_coef 400 : La_tqwt_entropy_log_dec_15 500 :
tqwt_medianValue_dec_7
600 : tqwt_stdValue_dec_35 700 : tqwt_skewnessValue_dec_27
univariate_columns <- c("caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC")
##top variables
topvar <- c(1:length(varlist)) <= TopVariables
tableRaw <- univarRAW$orderframe[topvar,univariate_columns]
pander::pander(tableRaw)
| caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | |
|---|---|---|---|---|---|---|
| std_delta_delta_log_energy | 23.4 | 0.469 | 22.8 | 0.461 | 0.653 | 0.798 |
| std_delta_log_energy | 24.3 | 0.477 | 23.8 | 0.441 | 0.634 | 0.794 |
| std_9th_delta_delta | 23.6 | 0.242 | 23.4 | 0.171 | 0.746 | 0.787 |
| std_8th_delta_delta | 23.7 | 0.240 | 23.4 | 0.150 | 0.725 | 0.780 |
| std_7th_delta_delta | 23.7 | 0.261 | 23.5 | 0.188 | 0.931 | 0.776 |
| tqwt_entropy_log_dec_12 | -39.6 | 0.239 | -39.4 | 0.240 | 0.887 | 0.770 |
| std_6th_delta_delta | 23.8 | 0.277 | 23.5 | 0.172 | 0.945 | 0.768 |
| std_8th_delta | 24.4 | 0.245 | 24.2 | 0.163 | 0.981 | 0.767 |
| std_9th_delta | 24.4 | 0.249 | 24.1 | 0.185 | 0.398 | 0.764 |
| tqwt_entropy_shannon_dec_12 | 30.3 | 1.993 | 32.1 | 1.703 | 0.196 | 0.763 |
topLAvar <- univarDe$orderframe$Name[str_detect(univarDe$orderframe$Name,"La_")]
topLAvar <- unique(c(univarDe$orderframe$Name[topvar],topLAvar[1:as.integer(TopVariables/2)]))
finalTable <- univarDe$orderframe[topLAvar,univariate_columns]
pander::pander(finalTable)
| caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | |
|---|---|---|---|---|---|---|
| std_delta_log_energy | 24.335 | 0.477 | 23.810 | 0.441 | 6.34e-01 | 0.794 |
| std_9th_delta | 24.365 | 0.249 | 24.134 | 0.185 | 3.98e-01 | 0.764 |
| La_tqwt_entropy_log_dec_28 | -0.633 | 0.430 | -0.819 | 0.273 | 1.25e-07 | 0.758 |
| tqwt_entropy_log_dec_13 | -39.232 | 0.280 | -38.985 | 0.259 | 7.85e-01 | 0.757 |
| mean_MFCC_2nd_coef | 21.360 | 18.112 | 1.716 | 27.881 | 4.61e-07 | 0.753 |
| La_tqwt_energy_dec_33 | 1.020 | 0.115 | 1.133 | 0.148 | 6.93e-01 | 0.746 |
| La_tqwt_kurtosisValue_dec_33 | 3.501 | 0.262 | 3.258 | 0.389 | 2.39e-01 | 0.746 |
| std_12th_delta | 24.239 | 0.239 | 24.055 | 0.193 | 3.42e-01 | 0.734 |
| La_apq11Shimmer | 2.150 | 0.161 | 2.031 | 0.133 | 4.19e-01 | 0.734 |
| La_tqwt_stdValue_dec_32 | 1.137 | 0.203 | 0.926 | 0.323 | 3.47e-01 | 0.733 |
dc <- getLatentCoefficients(DEdataframe)
fscores <- attr(DEdataframe,"fscore")
pander::pander(c(mean=mean(sapply(dc,length)),total=length(dc),fraction=length(dc)/(ncol(dataframe)-1)))
| mean | total | fraction |
|---|---|---|
| 2.65 | 460 | 0.617 |
theCharformulas <- attr(dc,"LatentCharFormulas")
finalTable <- rbind(finalTable,tableRaw[topvar[!(topvar %in% topLAvar)],univariate_columns])
orgnamez <- rownames(finalTable)
orgnamez <- str_remove_all(orgnamez,"La_")
finalTable$RAWAUC <- univarRAW$orderframe[orgnamez,"ROCAUC"]
finalTable$DecorFormula <- theCharformulas[rownames(finalTable)]
finalTable$fscores <- fscores[rownames(finalTable)]
Final_Columns <- c("DecorFormula","caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC","RAWAUC","fscores")
finalTable <- finalTable[order(-finalTable$ROCAUC),]
pander::pander(finalTable[,Final_Columns])
| DecorFormula | caseMean | caseStd | controlMean | controlStd | controlKSP | ROCAUC | RAWAUC | fscores | |
|---|---|---|---|---|---|---|---|---|---|
| std_delta_delta_log_energy | NA | 23.357 | 0.469 | 22.794 | 0.461 | 6.53e-01 | 0.798 | 0.798 | NA |
| std_delta_log_energy | NA | 24.335 | 0.477 | 23.810 | 0.441 | 6.34e-01 | 0.794 | 0.794 | 2 |
| std_delta_log_energy1 | NA | 24.335 | 0.477 | 23.810 | 0.441 | 6.34e-01 | 0.794 | NA | NA |
| std_9th_delta_delta | NA | 23.630 | 0.242 | 23.388 | 0.171 | 7.46e-01 | 0.787 | 0.787 | NA |
| std_8th_delta_delta | NA | 23.660 | 0.240 | 23.428 | 0.150 | 7.25e-01 | 0.780 | 0.780 | NA |
| std_7th_delta_delta | NA | 23.732 | 0.261 | 23.479 | 0.188 | 9.31e-01 | 0.776 | 0.776 | NA |
| tqwt_entropy_log_dec_12 | NA | -39.634 | 0.239 | -39.390 | 0.240 | 8.87e-01 | 0.770 | 0.770 | NA |
| std_6th_delta_delta | NA | 23.800 | 0.277 | 23.548 | 0.172 | 9.45e-01 | 0.768 | 0.768 | NA |
| std_8th_delta | NA | 24.406 | 0.245 | 24.175 | 0.163 | 9.81e-01 | 0.767 | 0.767 | NA |
| std_9th_delta | NA | 24.365 | 0.249 | 24.134 | 0.185 | 3.98e-01 | 0.764 | 0.764 | 5 |
| std_9th_delta1 | NA | 24.365 | 0.249 | 24.134 | 0.185 | 3.98e-01 | 0.764 | NA | NA |
| tqwt_entropy_shannon_dec_12 | NA | 30.301 | 1.993 | 32.106 | 1.703 | 1.96e-01 | 0.763 | 0.763 | NA |
| La_tqwt_entropy_log_dec_28 | + tqwt_entropy_log_dec_28 - (0.981)tqwt_entropy_log_dec_29 | -0.633 | 0.430 | -0.819 | 0.273 | 1.25e-07 | 0.758 | 0.654 | -1 |
| tqwt_entropy_log_dec_13 | NA | -39.232 | 0.280 | -38.985 | 0.259 | 7.85e-01 | 0.757 | 0.757 | 4 |
| mean_MFCC_2nd_coef | NA | 21.360 | 18.112 | 1.716 | 27.881 | 4.61e-07 | 0.753 | 0.753 | 0 |
| La_tqwt_energy_dec_33 | - (1.014)tqwt_energy_dec_32 + tqwt_energy_dec_33 + (1.770)tqwt_stdValue_dec_32 - (1.705)tqwt_stdValue_dec_33 | 1.020 | 0.115 | 1.133 | 0.148 | 6.93e-01 | 0.746 | 0.509 | -3 |
| La_tqwt_kurtosisValue_dec_33 | - (0.887)tqwt_kurtosisValue_dec_32 + tqwt_kurtosisValue_dec_33 | 3.501 | 0.262 | 3.258 | 0.389 | 2.39e-01 | 0.746 | 0.628 | -1 |
| std_12th_delta | NA | 24.239 | 0.239 | 24.055 | 0.193 | 3.42e-01 | 0.734 | 0.734 | 2 |
| La_apq11Shimmer | - (0.907)locShimmer + apq11Shimmer | 2.150 | 0.161 | 2.031 | 0.133 | 4.19e-01 | 0.734 | 0.713 | -1 |
| La_tqwt_stdValue_dec_32 | + tqwt_stdValue_dec_32 - (0.963)tqwt_stdValue_dec_33 | 1.137 | 0.203 | 0.926 | 0.323 | 3.47e-01 | 0.733 | 0.573 | 4 |
featuresnames <- colnames(dataframe)[colnames(dataframe) != outcome]
pc <- prcomp(dataframe[,iscontinous],center = TRUE,scale. = TRUE) #principal components
predPCA <- predict(pc,dataframe[,iscontinous])
PCAdataframe <- as.data.frame(cbind(predPCA,dataframe[,!iscontinous]))
colnames(PCAdataframe) <- c(colnames(predPCA),colnames(dataframe)[!iscontinous])
#plot(PCAdataframe[,colnames(PCAdataframe)!=outcome],col=dataframe[,outcome],cex=0.65,cex.lab=0.5,cex.axis=0.75,cex.sub=0.5,cex.main=0.75)
#pander::pander(pc$rotation)
PCACor <- cor(PCAdataframe[,colnames(PCAdataframe) != outcome])
gplots::heatmap.2(abs(PCACor),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "PCA Correlation",
cexRow = 0.5,
cexCol = 0.5,
srtCol=45,
srtRow= -45,
key.title=NA,
key.xlab="Pearson Correlation",
xlab="Feature", ylab="Feature")
EFAdataframe <- dataframeScaled
if (length(iscontinous) < 2000)
{
topred <- min(length(iscontinous),nrow(dataframeScaled),ncol(predPCA)/2)
if (topred < 2) topred <- 2
uls <- fa(dataframeScaled[,iscontinous],nfactors=topred,rotate="varimax",warnings=FALSE) # EFA analysis
predEFA <- predict(uls,dataframeScaled[,iscontinous])
EFAdataframe <- as.data.frame(cbind(predEFA,dataframeScaled[,!iscontinous]))
colnames(EFAdataframe) <- c(colnames(predEFA),colnames(dataframeScaled)[!iscontinous])
EFACor <- cor(EFAdataframe[,colnames(EFAdataframe) != outcome])
gplots::heatmap.2(abs(EFACor),
trace = "none",
# scale = "row",
mar = c(5,5),
col=rev(heat.colors(5)),
main = "EFA Correlation",
cexRow = 0.5,
cexCol = 0.5,
srtCol=45,
srtRow= -45,
key.title=NA,
key.xlab="Pearson Correlation",
xlab="Feature", ylab="Feature")
}
par(op)
par(xpd = TRUE)
dataframe[,outcome] <- factor(dataframe[,outcome])
rawmodel <- rpart(paste(outcome,"~."),dataframe,control=rpart.control(maxdepth=3))
pr <- predict(rawmodel,dataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(rawmodel,main="Raw",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(rawmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,dataframe[,outcome]==0))
}
pander::pander(table(dataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 39 | 25 |
| 1 | 3 | 185 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.889 | 0.843 | 0.925 |
| 3 | se | 0.984 | 0.954 | 0.997 |
| 4 | sp | 0.609 | 0.479 | 0.729 |
| 6 | diag.or | 96.200 | 27.662 | 334.550 |
par(op)
par(xpd = TRUE)
DEdataframe[,outcome] <- factor(DEdataframe[,outcome])
IDeAmodel <- rpart(paste(outcome,"~."),DEdataframe[,c(outcome,varlistcV)],control=rpart.control(maxdepth=3))
pr <- predict(IDeAmodel,DEdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(IDeAmodel,main="ILAA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(IDeAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,DEdataframe[,outcome]==0))
}
pander::pander(table(DEdataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 52 | 12 |
| 1 | 12 | 176 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.905 | 0.862 | 0.938 |
| 3 | se | 0.936 | 0.891 | 0.967 |
| 4 | sp | 0.812 | 0.695 | 0.899 |
| 6 | diag.or | 63.556 | 26.952 | 149.873 |
par(op)
par(xpd = TRUE)
PCAdataframe[,outcome] <- factor(PCAdataframe[,outcome])
PCAmodel <- rpart(paste(outcome,"~."),PCAdataframe,control=rpart.control(maxdepth=3))
pr <- predict(PCAmodel,PCAdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(PCAmodel,main="PCA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(PCAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,PCAdataframe[,outcome]==0))
}
pander::pander(table(PCAdataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 40 | 24 |
| 1 | 14 | 174 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.849 | 0.799 | 0.891 |
| 3 | se | 0.926 | 0.878 | 0.959 |
| 4 | sp | 0.625 | 0.495 | 0.743 |
| 6 | diag.or | 20.714 | 9.850 | 43.561 |
par(op)
EFAdataframe[,outcome] <- factor(EFAdataframe[,outcome])
EFAmodel <- rpart(paste(outcome,"~."),EFAdataframe,control=rpart.control(maxdepth=3))
pr <- predict(EFAmodel,EFAdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
plot(EFAmodel,main="EFA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
text(EFAmodel, use.n = TRUE,cex=0.75)
ptab <- epiR::epi.tests(table(pr==0,EFAdataframe[,outcome]==0))
}
pander::pander(table(EFAdataframe[,outcome],pr))
| 0 | 1 | |
|---|---|---|
| 0 | 28 | 36 |
| 1 | 4 | 184 |
pander::pander(ptab$detail[c(5,3,4,6),])
| statistic | est | lower | upper | |
|---|---|---|---|---|
| 5 | diag.ac | 0.841 | 0.790 | 0.884 |
| 3 | se | 0.979 | 0.946 | 0.994 |
| 4 | sp | 0.438 | 0.314 | 0.567 |
| 6 | diag.or | 35.778 | 11.828 | 108.223 |
par(op)